package com.platform.os.util;

import java.io.File;
import java.util.Date;

/** 应用日志操作.
 * @author KangJun 2007-11-10.
 */
public class Logger {
	private static String logDir = "/logs";
	private static String fileExtend = "txt";
	private static String newLineChar = "\n";
	
	static{
		File dir=new File(FileInfo.getFilePath(logDir,""));
		if(!dir.exists()){
			dir.mkdir();
		}
	}
	/** 写日志.
	 * @param fileName
	 * @param message
	 * @param className
	 */
	public static void write(String fileName, String message, String className) {
		StringBuffer content = new StringBuffer()
		.append(new Date())
		.append("|")
		.append(message)
		.append("|")
		.append(className)
		.append(newLineChar);
		String filePath = FileInfo.getFilePath(logDir, FileInfo.getFullFileName(fileName, fileExtend));
		FileHandle.appendFile(filePath, content.toString());
	}
}
